#!/usr/bin/env python

import wx
import view
import model
import component
import presenter
import interactor

from _meta import Meta

class App(component.App, wx.App):
    """Miyuki application"""
    
    def __init__(self, *args, **kwargs):
        wx.App.__init__(self, *args, **kwargs)
        meta = Meta()
        
    def OnInit(self):
        v = view.Miyuki()
        i = interactor.Miyuki()
        p = presenter.Miyuki(v, i)
        v.Show()
        return True
    
    def openDb(self, echo=False):
        database = 'Lucky Star.db'
        driver = "sqlite"
        url = model.sa.engine.url.URL(driver, database=database)
        engine = model.sa.create_engine(url, echo=echo)
        model.init(engine)
        session = model.DbSession()
        model.metadata.create_all(engine)
        return session
    